package pack.actions;

import com.jme.math.Vector3f;
import com.jme.util.Timer;

import pack.characters.Io;
import pack.projectiles.ProjectileFactory;
import pack.projectiles.ProjectileFactory.ProjectileType;


public class IoLumenAction implements Runnable 
{
    private float sfxTimeout = 0.1f;
    private float lastSFxPlayed = 0;
    private Io player = null;
    
	public IoLumenAction(final Io player){
		this.player = player;
	}
	
	public void run() 
	{
        Vector3f direction = player.getNode().getLocalRotation().getRotationColumn(2);
        
        player.getNode().updateWorldVectors();
        player.getCrossHair().updateWorldVectors();
        
        ProjectileFactory.get().createProjectile(ProjectileType.LUMEN).fire(
                direction,
                player.getCrossHair().getWorldTranslation(),
                player.getNode().getWorldRotation());
        
        float current = Timer.getTimer().getTimeInSeconds(); 
        if (lastSFxPlayed + sfxTimeout < current) {
            //SoundUtil.get().playSFX(SoundUtil.BG_BULLET_SHOT);
            lastSFxPlayed = current;
        }        
		
	}
}
